#include "mtgplayer.h"

MTGPLayer::MTGPLayer(CardPool *pool) :
    QObject(0)
{       
    m_CardPool = new CardPool();
    if (pool != 0)
        m_CardPool->fromXmlDefinition(pool->toXmlDefinition());
}

void MTGPLayer::moveCardTo(AbstractCard *card, AbstractCard::CardState state)
{
    m_InGame.remove(m_InGame.indexOf(card));
    m_InGrave.remove(m_InGrave.indexOf(card));
    m_InHand.remove(m_InHand.indexOf(card));

    switch (state)
    {
    case AbstractCard::state_InPool:
        {

            break;
        }

    case AbstractCard::state_InHand:
        {
            m_InHand.push_front(card);
            break;
        }

    case AbstractCard::state_InGame:
        {
            m_InGame.push_front(card);
            break;
        }
    case AbstractCard::state_InGrave:
        {
            m_InGrave.push_front(card);
            break;
        }
    case AbstractCard::state_OutGame:
        {
            m_CardPool->RemoveCard(card);
            break;
        }
    }

    card->setCardState(state);
}
